<?php 
/**
* Copyright (C)2001-2099 Zeai.cn All rights reserved.
* E-Mail：supdes#qq.com　QQ:797311
* http://www.zeai.cn
* http://www.yzlove.com
* Last update 2021/06/15 by supdes
*/
require_once '../sub/init.php';
require_once ZEAI.'cache/config_wxgzh.php';
$logincode = trimhtml($logincode);
$ifwxlogin=(!empty($_ZEAI['wx_gzh_appid']) && !empty($_ZEAI['wx_gzh_appsecret']) && !empty($_GZH['wx_gzh_token']))?true:false;
if(!$ifwxlogin)alert('请检查微信公众号参数是否配置正确','-1');
if(!is_weixin())alert('请在微信里扫码','-1');
if(str_len($logincode)==32){
	if(str_len($cook_adm_openid)>20){
		$server_openid = $cook_adm_openid;
	}else{
		$server_openid = wx_get_openid(0);
		setcookie("cook_adm_openid",$server_openid,time()+31536000,"/",$_ZEAI['CookDomain']);
	}
	if (str_len($server_openid) >20){
		require_once ZEAI.'sub/conn.php';
		$row = $db->ROW(__TBL_TMP__,"id","logincode='$logincode'");
		if ($row){
			$db->query("UPDATE ".__TBL_TMP__." SET openid='$server_openid' WHERE logincode='$logincode'");
			alert('扫码成功，请在电脑上操作','-1');
		}else{
		  alert('参数错误，请联系管理员','-1');
		}
	}
}else{
	alert('参数错误，请联系管理员','-1');
}
?>